// 引入api
import {reqCategory,reqBannerList} from '@/api';
const state={
    category:[],
    // 存储bannerList轮播图的数据
    bannerList:[],
};
const mutations={
    CATEGORYLIST:(state,payload) =>{
        state.category=payload;
    },
    BANNERLIST:(state,payload) =>{
        state.bannerList=payload;
    }
};

const actions={
    // 书写categoryList类型action
    categoryList:async({state,dispatch,commit})=>{
       let result=await reqCategory();
       console.log(result);
       if (result.code==200) {
           commit('CATEGORYLIST',result.data)
       }
    },
    // bannerList 类型的action
    bannerList:async({state,dispatch,commit})=>{
        // console.log(state,commit,dispatch);
        let result=await reqBannerList();
        console.log(result);
        // console.log(result.data);
        if (result.code==200) {
            commit("BANNERLIST",result.data);
        }
    }

};

const getters={};

export default{
    state,
    mutations,
    actions,
    getters,
}